#ifndef ___CLAN_OP__H__    
#define ___CLAN_OP__H__

#include <interface/data_op/clan.h>

namespace aot{ namespace data{

class clan_info_impl : public iclan_info
{
public:
    virtual ~clan_info_impl(){;}
    clan_info_impl()
    {
        type = 0;
        picture = 0;
        province = 0;
        city = 0;
        auth = 0;
        attribute = 0;
        version = 0;
        notify_mode = 0;
        save_to_server = 0;
        
        clan_id = &clan_id_impl;
        clan_name = &clan_name_impl;
        creater_id = &creater_id_impl;
        type_name = &type_name_impl;
        keyword = &keyword_impl;
        broadcast = &broadcast_impl;
        remark = &remark_impl; 
        create_datetime = &create_datetime_impl;
        note = &note_impl;
    }
public:
    virtual  bool clone(iclan_info** out) 
    {
        clan_info_impl* p = new clan_info_impl();
        *out = p;
        return p->assign(this);
    }
    virtual  bool assign(const iclan_info* in) 
    {
        if (NULL==in)
            return false;

        clan_info_impl* p = (clan_info_impl*) in;
        *this = *p;

        clan_id = &clan_id_impl;
        clan_name = &clan_name_impl;
        creater_id = &creater_id_impl;
        type_name = &type_name_impl;
        keyword = &keyword_impl;
        broadcast = &broadcast_impl;
        remark = &remark_impl; 
        create_datetime = &create_datetime_impl;
        note = &note_impl;
        return true;
    }
public:
    aot::tt::str_impl clan_id_impl;
    aot::tt::str_impl clan_name_impl;
    aot::tt::str_impl creater_id_impl;
    aot::tt::str_impl type_name_impl;
    aot::tt::str_impl keyword_impl;
    aot::tt::str_impl broadcast_impl;
    aot::tt::str_impl remark_impl; 
    aot::tt::str_impl create_datetime_impl;
    aot::tt::str_impl note_impl; /// 2010.2.23
    
};

class clan_op_impl : public aot::data::iclan_op
{
public:
    clan_op_impl(void);
public:
    virtual ~clan_op_impl(void);
public:    
    virtual bool insert(const iclan_info* p);
    virtual bool del(const char* clan_id); 
    virtual bool del_all();
    virtual bool update(const iclan_info* p);

    virtual bool read(const char* clan_id, isqlite3_table** out);
    virtual bool read(const char* clan_id, iclan_info* out);
    virtual bool read(const char* clan_id, iclan_info** out);

    virtual bool get_clans(isqlite3_table** out);
    virtual int get_members_count(const char* clan_id);
};

}} /* end namespace aot/data*/

#endif // ___CLAN_OP__H__
